#pragma once
#include "SOM.h"
#include "Hebbian.h"
#include "BasicFunction.h"
class CCrossNet
{
public:
	//constructor
	CCrossNet(int r_net1, int c_net1, int d_net1, int r_net2, int c_net2, int d_net2, int tCycle);
	//network training
	//normalize data before training, otherwise, cause som to overflow.
	void			NetTraining(double** input1, double** input2, int num_input);
	//get cross link
	int				NetGet2(double* input_net1);
	int				NetGet1(double* input_net2);
	//get som
	int				NetGetSom1(double* input_net1);
	int				NetGetSom2(double* input_net2);
	//get the input data through cross link
	double*			NetGetData2(double* input_net1);
	double*			NetGetData1(double* input_net2);
	//destroy the network
	bool			NetDestroy(void);
	//set illustration or not
	void			NetIllustration(bool flag);
	//get the winners
	int*			NetGetWinners1(void);
	int*			NetGetWinners2(void);
	bool			IsNetDestroy(void);
	//get the data of the first SOM
	double**		NetGetSOM1Lattice(void);
	double**		NetGetSOM2Lattice(void);
	//get the links data of the hebbian
	double**		NetGetHebbian(void);
	//get the size and data dimension of the cross net
	void			NetGetDimension(int* m_SizeX1, int* m_SizeY1, int* m_SizeX2, int* m_SizeY2, int* m_DataDimension1, int* m_DataDimension2);
	//load the cross modal from three different matrix
	void			NetLoadFromMatrix(double** m_SOM1, double** m_SOM2, double** m_Hebbian, int m_SizeX1, int m_SizeY1, int m_DataDimension1, int m_SizeX2, int m_SizeY2, int m_DataDimension2);

private:
	double**		somLattice1;		//output layer of first som
	double**		somLattice2;		//output layer of second som
	double**		inputData1;			//pointer to the inputdata1
	double**		inputData2;			//pointer to the inputdata2

	int				trainCycle;			//training cycles

	CSOM*			net_som1;			//first som
	CSOM*			net_som2;			//second som
	CHebbian*		net_hebbian;		//hebbian link

	int				net1_r;				//number of rows in first som
	int				net1_c;				//number of columsn in second som
	int				net1_d;				//dimension of the first som
	int				net2_r;				//number of rows in second som
	int				net2_c;				//number of columns in the second som
	int				net2_d;				//dimension of the second som

	bool			net_trained;		//is multinet trained?

	bool			net_destroyed;		//is the net destroyed?

	bool			net_loaded;			//is the net loaded from matrix

	CBasicFunction	bf;					//basic function class
public:
	~CCrossNet(void);
};
